package org.familysearch.fsapi.gwt.server.dao;

import java.io.DataInputStream;
import java.io.InputStream;

import org.apache.commons.httpclient.HttpClient;

public abstract class DAO {

	protected boolean authenticated = false;
	protected String sessionID = "";
	protected HttpClient client = new HttpClient();
	
	/*
	public String getSessionID() {
		return sessionID;
	}

	public void setSessionID(String sessionID) {
		this.sessionID = sessionID;
	}
	*/
	
	protected String parseInputStream(InputStream inputStream)
	{
		DataInputStream dataInputStream = new DataInputStream(inputStream);
		StringBuffer sb = new StringBuffer();
		try
		{
			String line = null;
			while((line=dataInputStream.readLine()) != null)
			{
				sb.append(line+"\n");
			}
		}
		catch(Exception ex)
		{
			ex.getMessage();
		}
		finally
		{
			try
			{
				inputStream.close();
			}
			catch(Exception ex)
			{
				
			}
		}
		return sb.toString();
	}	
	


	protected boolean isAuthenticated() {
		return authenticated;
	}

	protected void setAuthenticated(boolean authenticated) {
		this.authenticated = authenticated;
	}	
}
